package com.remon.quartz.service.impl;

import com.remon.quartz.dao.SimpleTriggerResp;
import com.remon.quartz.entity.SimpleTrigger;
import com.remon.quartz.service.SimpleTriggerService;
import com.remon.quartz.vo.PageRes;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

/**
 * 简单任务管理器逻辑处理类接口实现类
 *
 * @author remon
 * @create 2018-09-04 16:55
 **/
@Slf4j
@Service
public class SimpleTriggerServiceImpl implements SimpleTriggerService {

    /**
     * 简单任务管理器数据库dao 操作对象
     */
    private final SimpleTriggerResp simpleTriggerResp;

    @Autowired
    public SimpleTriggerServiceImpl(SimpleTriggerResp simpleTriggerResp) {
        this.simpleTriggerResp = simpleTriggerResp;
    }

    /**
     * 分页查询任务触发器查询数据库中当前所有任务
     *
     * @param pageNo
     * @param pageSize
     * @return
     */
    public PageRes<SimpleTrigger> page(Integer pageNo, Integer pageSize) {
        Pageable pageable = PageRequest.of(pageNo, pageSize);//new PageRequest(pageNo,pageSize);
        return new PageRes<>(simpleTriggerResp.findAll(pageable));
    }

}
